class quanbu {
    constructor() {
        this.jiedian();
        this.qiehuan();
        this.erduo();
        //this.zuoerduo();
        this.jishiqi()
    }
    jiedian() {
        this.ulLisObj = document.querySelectorAll('.lunBo li');
        this.olLisObj = document.querySelectorAll('.Ol li');
        this.prev = document.querySelector('#goPrev');
        this.next = document.querySelector('#goNext');
    }
    lastIndex = 0;
    index = 0;
    qiehuan() {
        this.olLisObj.forEach((li, k) => {
            li.onclick = () => {
                this.lastIndex = this.index;
                this.index = k;
                this.change();
            }
        })
    }
    change() {
        this.ulLisObj[this.lastIndex].className = '';
        this.olLisObj[this.lastIndex].className = '';
        this.ulLisObj[this.index].className = 'ac';
        this.olLisObj[this.index].className = 'ac';

    }

    erduo() {
        this.next.onclick = () => {
            this.lastIndex = this.index;
            this.index++;
            if (this.index > this.ulLisObj.length - 1) this.index = 0;
            this.change();
        }
        this.prev.onclick = () => {
            this.lastIndex = this.index;
            this.index--;
            if (this.index < 0) this.index = this.ulLisObj.length - 1;
            this.change()
        }
    }
    
    times = ''
    jishiqi() {
        this.times = setInterval(function () {
            this.next.onclick();
        }, 1000)

        this.next.parentNode.onmouseover =  ()=> {
            clearInterval( this.times);
        }
        this.next.parentNode.onmouseout =  ()=> {
            this.times = setInterval( ()=> {
                this.next.onclick();
            }, 2000)
        }
    }

}
new quanbu;